﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using OpusSuite.Utility;

namespace OpusSuite.Models.Model.Shared
{
    [Table("phone")]
    public class Phone : ModelBase
    {
        [Key]
        public int Id { get; set; }

        public int TypeValue { get; set; }
        public Enums.CommunicationPhoneType Type
        {
            get { return (Enums.CommunicationPhoneType)TypeValue; }
            set { TypeValue = (int)value; }
        }

        [StringLength(256)]
        public string Value { get; set; }
    }

    [Table("email")]
    public class Email : ModelBase
    {
        [Key]
        public int Id { get; set; }

        public int TypeValue { get; set; }
        public Enums.CommunicationEmailType Type
        {
            get { return (Enums.CommunicationEmailType)TypeValue; }
            set { TypeValue = (int)value; }
        }

        [StringLength(256)]
        public string Value { get; set; }
    }

    [Table("fax")]
    public class Fax : ModelBase
    {
        [Key]
        public int Id { get; set; }

        public int TypeValue { get; set; }
        public Enums.CommunicationFaxType Type
        {
            get { return (Enums.CommunicationFaxType)TypeValue; }
            set { TypeValue = (int)value; }
        }

        [StringLength(256)]
        public string Value { get; set; }
    }

    [Table("website")]
    public class Website : ModelBase
    {
        [Key]
        public int Id { get; set; }

        public int TypeValue { get; set; }
        public Enums.CommunicationWebsiteType Type
        {
            get { return (Enums.CommunicationWebsiteType)TypeValue; }
            set { TypeValue = (int)value; }
        }

        [StringLength(256)]
        public string Value { get; set; }
    }

    public abstract class Communication : ModelBase, IStaticBase
    {
        [Key]
        public int Id { get; set; }

        [StringLength(30)]
        public string Code { get; set; }

        public virtual ReportingStatus ReportingStatus { get; set; }

        public int TypeValue { get; set; }
        public Enums.CommunicationType Type
        {
            get { return (Enums.CommunicationType)TypeValue; }
            set { TypeValue = (int)value; }
        }

        public virtual IList<Phone> Phone { get; set; }
        public virtual IList<Fax> Fax { get; set; }
        public virtual IList<Email> Email { get; set; }
        public virtual IList<Website> Website { get; set; }
    }

    [Table("personcommunication")]
    public class PersonCommunication : Communication
    {
        public int PreferredPhoneTypeValue { get; set; }
        public Enums.CommunicationPhoneType PreferredPhoneType
        {
            get { return (Enums.CommunicationPhoneType)PreferredPhoneTypeValue; }
            set { PreferredPhoneTypeValue = (int)value; }
        }

        public int PreferredEmailTypeValue { get; set; }
        public Enums.CommunicationEmailType PreferredEmailType
        {
            get { return (Enums.CommunicationEmailType)PreferredEmailTypeValue; }
            set { PreferredEmailTypeValue = (int)value; }
        }

        public int PreferredFaxTypeValue { get; set; }
        public Enums.CommunicationFaxType PreferredFaxType
        {
            get { return (Enums.CommunicationFaxType)PreferredFaxTypeValue; }
            set { PreferredFaxTypeValue = (int)value; }
        }
    }

    [Table("organisationcommunication")]
    public class OrganisationCommunication : Communication
    {
        public int PreferredPhoneTypeValue { get; set; }
        public Enums.CommunicationPhoneType PreferredPhoneType
        {
            get { return (Enums.CommunicationPhoneType)PreferredPhoneTypeValue; }
            set { PreferredPhoneTypeValue = (int)value; }
        }

        public int PreferredEmailTypeValue { get; set; }
        public Enums.CommunicationEmailType PreferredEmailType
        {
            get { return (Enums.CommunicationEmailType)PreferredEmailTypeValue; }
            set { PreferredEmailTypeValue = (int)value; }
        }

        public int PreferredFaxTypeValue { get; set; }
        public Enums.CommunicationFaxType PreferredFaxType
        {
            get { return (Enums.CommunicationFaxType)PreferredFaxTypeValue; }
            set { PreferredFaxTypeValue = (int)value; }
        }
    }

    [Table("officecommunication")]
    public class OfficeCommunication : Communication
    {
        public int PreferredPhoneTypeValue { get; set; }
        public Enums.CommunicationPhoneType PreferredPhoneType
        {
            get { return (Enums.CommunicationPhoneType)PreferredPhoneTypeValue; }
            set { PreferredPhoneTypeValue = (int)value; }
        }

        public int PreferredEmailTypeValue { get; set; }
        public Enums.CommunicationEmailType PreferredEmailType
        {
            get { return (Enums.CommunicationEmailType)PreferredEmailTypeValue; }
            set { PreferredEmailTypeValue = (int)value; }
        }

        public int PreferredFaxTypeValue { get; set; }
        public Enums.CommunicationFaxType PreferredFaxType
        {
            get { return (Enums.CommunicationFaxType)PreferredFaxTypeValue; }
            set { PreferredFaxTypeValue = (int)value; }
        }
    }
}
